<?php
class Pay_failure_log_model extends CI_Model
{
    private $table = 'pay_failure_log';
    
    public function findByOrderSn($order_sn)
    {
        $this->db->where('order_sn', $order_sn);
        $result = $this->db->get($this->table);
        if ($result->num_rows() > 0) {
            return $result->row();
        }
        return false;
    }
    
    public function insertPayFailureLog($order_sn, $postData, $response)
    {
        $data = array(
            'order_sn'     => $order_sn,
            'return_param' => serialize($postData),
            'error_body'   => serialize($response)
        );
        $this->db->insert($this->table, $data);
        return $this->db->insert_id();
    }
}